/*
 * commons is a based project implemented
 * Copyright (C) 2024 Jasmine
 */
package com.commons.core.enums;

/**
 * 是否删除的标识
 *
 * @author Jasmine
 * @version 1.0
 * @date 2020-11-09 13:19:19
 * @see DeleteEnum
 * @since JDK1.8
 */
@SuppressWarnings("all")
public enum DeleteEnum {
    DELETED(true, "已删除"),
    NOT_DELETED(false, "未删除"),;

    private Boolean code;
    private String desc;

    DeleteEnum(Boolean code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDescByCode(Boolean code) {
        if (code == null) {
            return "";
        } else {
            for (DeleteEnum enumItem : DeleteEnum.values()) {
                if (enumItem.getCode().equals(code)) {
                    return enumItem.getDesc();
                }
            }
            return "";
        }
    }

    public static DeleteEnum toEnum(Boolean code) {
        if (null == code) {
            return null;
        } else {
            for (DeleteEnum e : DeleteEnum.values()) {
                if (e.getCode().equals(code)) {
                    return e;
                }
            }
            return null;
        }
    }

    public Boolean getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
